package offer.easy;

import java.util.Arrays;

public class OddOrEven {

    public static void reOrderArray(int [] array) {
        int[] first = new int[array.length];
        int[] second = new int[array.length];
        int num1 = 0;
        int num2 = 0;
        for (int i = 0;i < array.length;i++) {
            if (array[i]%2 == 1) {
                first[num1++] = array[i];
            } else {
                second[num2++] = array[i];
            }
        }
        for (int i = 0;i < first.length;i++) {
            array[i] = first[i];
        }
        int i = 0;
        while(i < num2) {
            array[num1++] = second[i];
            i++;
        }
    }

    public static void main(String[] args) {
        int[] array = {1,2,4,5,6,7};
        System.out.println(Arrays.toString(array));
        reOrderArray(array);
        System.out.println(Arrays.toString(array));
    }
}
